#pragma once
#include"hash.h"
namespace MoYu
{
	template<class K>
	class unordered_set
	{

	public:
		struct SetOfT
		{
			const K& operator()(const K& p)
			{
				return p;
			}
		};
	private:
		typedef typename HashTable<K, const K, SetOfT>::Iterator iterator;
		typedef typename HashTable<K, const K, SetOfT>::Const_Iterator const_iterator;
		HashTable<K, const K, SetOfT> _ht;

	public:
		iterator begin()
		{
			return _ht.Begin();
		}
		iterator end()
		{
			return _ht.End();
		}
		const_iterator begin() const
		{
			return _ht.Begin();
		}
		const_iterator end() const
		{
			return _ht.End();
		}

		pair<iterator, bool> insert(const K& x)
		{
			return _ht.insert(x);
		}

		bool erase(const K& x)
		{
			return _ht.erase(x);
		}

		size_t size()
		{
			return _ht.size();
		}

		bool empty()
		{
			return _ht.empty();
		}

		iterator find()
		{
			return _ht.find();
		}

	};


	void test_set()
	{
		MoYu::unordered_set<int> st;
		st.insert(1);
		st.insert(11);
		st.insert(3);
		st.insert(4);
		st.insert(2);
		st.insert(12);
		st.insert(22);
		st.erase(22);
		//for (auto& e : st)
		//{
		//	cout << e << " ";
		//}
		//cout << endl;
		auto be = st.end();
		while (be != st.begin())
		{
			--be;
			cout << *be << " ";
		}
		cout << endl;
		while (be != st.end())
		{
			cout << *be << " ";
			++be;
		}
		cout << endl;
	}
}
